package com.ws.entity.test01;

/**
 * @author 王硕
 * @version jdk21
 * @className Caculator1
 * @description
 * @date 2024/11/5 16:47
 */
public class Caculator1 {
    public int number1;
    public String operator;
    public int number2;

    public Caculator1() {
    }

    public Caculator1(int number1, String operator, int number2) {
        this.number1 = number1;
        this.operator = operator;
        this.number2 = number2;
    }

    public int calculate() {
        switch (operator) {
            case "+":
                return number1 + number2;
            case "-":
                return number1 - number2;
            case "*":
                return number1 * number2;
            case "/":
                return number1 / number2;
            default:
                return 0;
        }
    }
}
